package org.jmc.refmanager.loader.util;

import java.io.File;
import java.io.IOException;
import java.io.Writer;

public final class FileUtil {

	/**
	 * 
	 * @param file
	 */
	public static void checkIfExists(File file) {
		if (!file.exists() || !file.canRead()) {
			if (file.isFile()) {
				throw new IllegalArgumentException("Impossible d'acceder au fichier '" + file + "'");
			} else {
				throw new IllegalArgumentException("Impossible d'acceder au repertoire '" + file + "'");
			}
		}
	}
	/**
	 * 
	 * @param out
	 */
	public static void closeQuietly(Writer out) {
		if (out != null) {
			try {
				out.close();
			} catch (IOException ignored) {
			}
		}
		
	}
}
